import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/themes/cvue/layout/index'

Vue.use(Router)
// 路由实例
const router = new Router({
  scrollBehavior (to, from, savedPosition) { // 路由滚动行为
    if (savedPosition) {
      return savedPosition
    } else {
      const position = {}
      if (to.hash) {
        position.selector = to.hash
      }
      if (to.matched.some(m => m.meta.scrollToTop)) {
        position.x = 0
        position.y = 0
      }
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve(position)
        }, 500)
      })
    }
  },
  routes: [
    {
      path: '/home',
      name: 'Home',
      component: () => import(/* webpackChunkName: "Home" */'../themes/cvue/layout/index'),
      children: [
        // {
        //   path: 'index',
        //   name: '首页',
        //   component: () => import(/* webpackChunkName: "Home" */'../themes/cvue/views/home/index')
        // },
        {
          path: 'index',
          name: '首页',
          component: () => import(/* webpackChunkName: "Home" */'../themes/cvue/views/course/prebook')
        },
        {
          path: 'prebook-history',
          name: '预约',
          component: () => import(/* webpackChunkName: "Home" */'../themes/cvue/views/course/prebookHistory')
        },
        {
          path: 'course-setting',
          name: '课程设置',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/setting.vue')
        },
        {
          path: 'course-setting-edit',
          name: '课程设置操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/settingEdit.vue')
        },
        {
          path: 'course-data',
          name: '课程签约',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/data.vue')
        },
        {
          path: 'course-data-edit',
          name: '课程签约操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/dataEdit.vue')
        },
        {
          path: 'coach',
          name: '教练',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/coach.vue')
        },
        {
          path: 'coach-edit',
          name: '教练操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/coachEdit.vue')
        },
        {
          path: 'member',
          name: '会员管理',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/member.vue')
        },
        {
          path: 'member-edit',
          name: '会员操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/memberEdit.vue')
        },
        {
          path: 'role',
          name: '角色管理',
          component: () => import(/* webpackChunkName: "user" */'../themes/cvue/views/user/role.vue')
        },
        {
          path: 'role-permission',
          name: '角色权限',
          component: () => import(/* webpackChunkName: "user" */'../themes/cvue/views/user/rolePermission.vue')
        },
        {
          path: 'shop-manage',
          name: '店铺管理',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/shop/index.vue')
        },
        {
          path: 'shop-edit',
          name: '店铺操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/shop/indexEdit.vue')
        },
        {
          path: 'order-manage',
          name: '订单管理',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/shop/order.vue')
        },
        {
          path: 'data-count',
          name: '数据统计',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/dataCount.vue')
        },
        {
          path: 'data-count-detail',
          name: '教练耗课明细',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/dataCountDetail.vue')
        },
        {
          path: 'data-count-cost-detail',
          name: '包时课程扣费明细',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/dataCountCostDetail.vue')
        },
        {
          path: 'agreement',
          name: '协议管理',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/agreement.vue')
        },
        {
          path: 'agreement-edit',
          name: '协议管理操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/agreementEdit.vue')
        },
        {
          path: 'device',
          name: '设备管理',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/device.vue')
        },
        {
          path: 'device-edit',
          name: '设备管理操作',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/deviceEdit.vue')
        },
        {
          path: 'ac-records',
          name: '门禁记录',
          component: () => import(/* webpackChunkName: "authCenter" */'../themes/cvue/views/course/acRecords.vue')
        }
      ]
    },
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import(/* webpackChunkName: "public" */'../themes/login/login')
    },
    {
      path: '/forget-password',
      name: 'forget-password',
      component: () => import(/* webpackChunkName: "public" */'../themes/login/forgetPassword')
    },
    {
      path: '*',
      redirect: '/error/404'
    },
    {
      path: '/error/403',
      name: 'Error403',
      component: () => import(/* webpackChunkName: "public" */'../themes/error/403')
    },
    {
      path: '/error/404',
      name: 'Error404',
      component: () => import(/* webpackChunkName: "public" */'../themes/error/404')
    }
  ]
})
export default router
